package com.zendaimoney.test.simulation.action.allinpay.utils;

import com.allinpay.XmlTools;

import java.math.BigDecimal;

/**
 * 通联工具类
 *
 * @author wulj
 */
public class AllinpayUtil {
    private static final int UNIT = 100;

    /**
     * xml报文签名
     *
     * @param xml
     * @param priFilePath 私钥路径
     * @param priFailPwd  私钥密码
     * @return
     * @throws Exception
     */
    public static String signMsg(String xml, String priFilePath,String priFailPwd) throws Exception {
        return XmlTools.signMsg(xml, priFilePath, priFailPwd, false);
    }

    /**
     * 元转换为分
     * @param amount
     * @return
     */
    public static BigDecimal yuanConvertFen(BigDecimal amount) {
        BigDecimal decUnit = BigDecimal.valueOf(UNIT);
        return amount.multiply(decUnit).setScale(0);
    }

}
